#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
	long long n, m, i, min, max;
	scanf("%lld %lld", &n, &m);
	for (i = n; i >= 1; i--)
	{
		if (m % i == 0 && n % i == 0)
		{
			min = i;
			break;
		}
	}
	max = m * n / min;
	printf("%lld\n", max + min);
	return 0;
}